let userConfig = {
  publicRuntimeConfig: {
    apiUrl: 'http://127.0.0.1:8000', // 修改为FastAPI后端地址
  }
}

/** @type {import('next').NextConfig} */
const nextConfig = {
  eslint: {
    ignoreDuringBuilds: true,
  },
  typescript: {
    ignoreBuildErrors: true,
  },
  images: {
    unoptimized: true,
  },
  publicRuntimeConfig: {
    apiUrl: 'http://127.0.0.1:8000', // 指向FastAPI后端
  },
  experimental: {
    webpackBuildWorker: true,
    parallelServerBuildTraces: true,
    parallelServerCompiles: true,
  },
}

Object.keys(userConfig).forEach(key => {
  if (typeof nextConfig[key] === 'object' && !Array.isArray(nextConfig[key])) {
    nextConfig[key] = {
      ...nextConfig[key],
      ...userConfig[key],
    }
  } else {
    nextConfig[key] = userConfig[key]
  }
});

export default nextConfig
